delete(instrfindall);
scom = serial('com6','BaudRate',115200);
fopen(scom);
Head = ' ';
End = ' ';

while(Head~='S')
    Head = fread(scom,1,'uint8');
end

while(End~='E')
    data(i) = fread(scom,1,'uint8');
    i = i+1;
end

fprintf('%3c',out);
fid=fopen('serial_data.txt','w+');
fprintf(fid,'%3c',out); 

fclose(fid);
fclose(scom);
delete(scom);
clear scom;